﻿<%@ Page Title="" Language="C#" MasterPageFile="~/_Default.Master" AutoEventWireup="true" CodeBehind="Detail.aspx.cs" Inherits="WebApplication.Art.Detail" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="../Content/Css/artDetail.css" rel="stylesheet" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <div class="layui-row layui-col-space15">
        <div class="layui-col-sm8">
            <div class="layui-panel">
                <div class="art-container">

                    <div class="top-line horizontal-layout">
                        <div class="match">
                            <span id="time">

                            </span>
                            <div class="el-divider el-divider--vertical">
                            </div>
                            共 <%=artwork.Pics.Count %> P
                            <span style="margin-left: 10px;">
                                <i class="iconfont icon-huo"></i>
                                <%=artwork.Hot %>
                            </span>
                        </div>
                        
                        <% if (Convert.ToInt32(Session["UID"]) == artwork.OwnerID)
                            { %>
                        <a class="btn-hover no-hover" href="Edit.aspx?mode=edit&id=<%=artwork.ArtworkID %>">编辑</a>
                        <a class="btn-hover no-hover" style="margin-left: 10px;" data="<%=artwork.ArtworkID %>" id="deleteBtn">删除</a>
                        <%} %>

                    </div>

                    <% foreach (string tag in tags)
                        { %>
                    <span class="el-tag el-tag--info el-tag--light" style="cursor: pointer;"><%=tag %></span>
                    <%} %>

                    <div class="app-divider" style="margin: 20px 0px;">
                        <b class="left"></b>
                        <span class="text normal"></span><b class="right"></b>
                    </div>

                    <div class="content">
                        <%=artwork.Content %>
                    </div>

                    <% foreach (string pic in artwork.Pics)
                        { %>
                    <img layer-src="<%=pic.Substring(1) %>""
                        src="<%=pic.Substring(1) %>"
                        class="item" />
                    <%} %>
                </div>
            </div>
        </div>
        <div class="layui-col-sm4">

            <div class="layui-panel">
                <div class="user-card">
                    <a href="/User/Arts.aspx?id=<%=artwork.OwnerID %>" class="">
                        <span class="avatar" style="width: 60px; height: 60px;">
                            <img
                                src="<%=artwork.Owner.AvatarUrl.Substring(1) %>" />
                        </span>
                    </a>
                    <div class="nickname">
                        <a href="/User/Arts.aspx?id=<%=artwork.OwnerID %>" class=""><%=artwork.Owner.NickName %>&nbsp;
                            <i class="iconfont <%=artwork.Owner.Sex==1?"icon-nv":artwork.Owner.Sex==2?"icon-nan":"" %>" style="font-size: 16px;"></i>
                        </a>
                    </div>
                    <div class="intro">
                        <%=artwork.Owner.Intro %>
                    </div>
                </div>
            </div>


            <div class="layui-panel mt1" style="padding:20px;">
                <button type="button" class="el-button match-width el-button--primary" dataId="<%=artwork.ArtworkID %>" id="likeBtn">
                    <span><i class="iconfont icon-zan"></i>&nbsp;
                        <%=artwork.IsLike?"已赞":"赞" %>&nbsp;<%=artwork.LikeCount %>
                    </span>
                </button>
            </div>


            <div class="layui-panel mt1">
                <div class="resume-card">
                    <div class="card-header">
                        <div>
                            接稿说明
                            <a href="/Resume.aspx?id=<%=artwork.OwnerID %>" class="" style="float: right;">更多<i class="el-icon-arrow-right"></i></a>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="resume-info">
                            <span class="label">简介：</span>
                            <div class="content"><%=(artwork.ResumeInfo.Intro=="" ||artwork.ResumeInfo.Intro==null)?"未填写": artwork.ResumeInfo.Intro %></div>
                        </div>
                        <div class="resume-info">
                            <span class="label">经验：</span>
                            <div class="content"><%=(artwork.ResumeInfo.Experience==""||artwork.ResumeInfo.Experience==null)?"未填写":artwork.ResumeInfo.Experience %></div>
                        </div>
                        <div class="resume-info">
                            <span class="label">联系：</span>
                            <div class="content"><%=(artwork.ResumeInfo.Contact == "" || artwork.ResumeInfo.Contact == null)?"未填写":artwork.ResumeInfo.Contact %></div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
    <script>
        //调用示例
        layer.photos({
            photos: '.art-container'
            , anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
        });

       

        $(function () {
            const timestamp = new Date("<%=artwork.CreatedAt.ToString().Replace("/","-") %>").getTime();
            $('#time').text(utils.timeFormat(timestamp));
            $('#likeBtn').on('click', e=> {
                const id = $(e.delegateTarget).attr('dataId');
                $.ajax({
                    url: '/Art/Handle.aspx',
                    method: "post",
                    data: {
                        action:"Like",
                        id
                    },
                    success: (msg) => {
                        location.reload();
                    }
                })
            })

            $('#deleteBtn').on('click', e => {
                layer.confirm('确定要删除该作品嘛?', function (index) {
                    let id = $(e.target).attr("data");

                    $.ajax({
                        url: '/Art/Handle.aspx',
                        method:"post",
                        data: {
                            action: 'Delete',
                            id
                        },
                        success: () => {
                            location.href = "/"
                        }
                    })
                    layer.close(index);
                });
            })
        })


    </script>

</asp:Content>
